Skip to content

Fix config.softmax_scale not being considered - #3698

Open
janEbert wants to merge 2 commits into
NVIDIA:mainfrom
janEbert:fix-softmax-scale
Open

Fix config.softmax_scale not being considered#3698
janEbert wants to merge 2 commits into
NVIDIA:mainfrom
janEbert:fix-softmax-scale

Conversation

@janEbert

@janEbert janEbert commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Previously, config.softmax_scale was sometimes ignored and the default used unconditionally. This is fine in most cases, but when softmax_scale is set, we do – of course – want to use it.

@janEbert
janEbert requested review from a team as code owners March 4, 2026 15:15
@svcnvidia-nemo-ci
svcnvidia-nemo-ci requested a review from a team March 4, 2026 15:16
@svcnvidia-nemo-ci svcnvidia-nemo-ci added this to the Core 0.16 milestone Mar 4, 2026
@Phlip79 Phlip79 added the Final Review PR is in the "final review" stage label Mar 4, 2026
* (
(1 / math.sqrt(self.q_head_dim))
if self.config.softmax_scale is None
else self.config.softmax_scale

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with the details of MLA... does it even make sense to have a configured softmax_scale for MLA? I'm wondering if we should instead fail in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could ask the same about standard Attention, right? :)
One argument that objectively speaks for allowing this would be a hypothetical μP implementation for MLA, which would likely make use of softmax_scale similar to how it's done for standard Attention.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For comparing this to standard attention, you can basically ignore the mscale stuff, that's just relevant for YaRN.

MLA defines its softmax_scale as (qk_head_dim + qk_pos_emb_head_dim)^-0.5. The first term in the sum is the same as in standard attention; the second term is the per-head dimensionality of the decoupled queries, which are part of the modified, decoupled RoPE for MLA.

@janEbert
janEbert force-pushed the fix-softmax-scale branch from 900a73f to 1922754 Compare March 10, 2026 22:02
@janEbert

janEbert commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

Fixed other places where it was missing and added non-functional unit tests.

@janEbert
janEbert force-pushed the fix-softmax-scale branch from 1922754 to e328f83 Compare March 10, 2026 22:07
ericharper

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Final Review PR is in the "final review" stage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants